package
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	
	
	public class InnerButton extends MovieClip
	{
		
		private var number:int;
		private var elevator:Elevator;
		private var state:Boolean;
		
		public function InnerButton(elevator:Elevator,pContainer:MovieClip,x:int,y:int,n:int=0)
		{
			reSet(x,y);
			number=n;
			this.gotoAndStop(n);
			this.addEventListener(MouseEvent.CLICK,mouseClick);
			this.elevator=elevator;
			pContainer.addChild(this);
			state=false;
			
			
			//this.add
			
			//this.addEventListener("task",eventTask);
			
			
		}
		
		public function reSet(x:int,y:int):void
		{
			this.x=x;
			this.y=y;
		}
		
		private function mouseClick(e:MouseEvent):void
		{
			this.gotoAndStop(number+20);
			//var task=new Task("task");
			//this.dispatchEvent(new Task("task"));
			if(state==false){
				elevator.addTask(new Task(number,"inner"));
				trace(number+"inner!");
				state=true;
			}
		}
		
		public function setBack():void
		{
			this.gotoAndStop(number);
			state=false;
		}
	}
}